package com.example.zwh.computershop.my_shopp;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.zwh.computershop.Myapp;
import com.example.zwh.computershop.R;
import com.example.zwh.computershop.androidUtil.ActivityCollector;
import com.example.zwh.computershop.order.OrderListActivity;

public class MyShopp_Fragment extends Fragment implements View.OnClickListener {
    private Intent intent;
    private Myapp myapp;
    private View mview;
    //订单页面
    private LinearLayout order_title;
    private LinearLayout myshop_waiting_pay;
    private LinearLayout myshop_waiting_receive;
    private LinearLayout myshop_waiting_comment;
    ImageView image;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        mview =  inflater.inflate(R.layout.fragment_my_shopp, container, false);


        initView();
        initEvent();
        ActivityCollector.addActivity(getActivity());
        return mview;
    }

    void initView() {
        myapp = (Myapp) getActivity().getApplication();
        image =  mview.findViewById(R.id.setup);

        order_title = mview.findViewById(R.id.order_title);
        myshop_waiting_pay = mview.findViewById(R.id.myshop_waiting_pay);
        myshop_waiting_receive = mview.findViewById(R.id.myshop_waiting_receive);
        myshop_waiting_comment = mview.findViewById(R.id.myshop_waiting_comment);
    }

    void initEvent() {
        image.setOnClickListener(this);

        order_title.setOnClickListener(this);
        myshop_waiting_pay.setOnClickListener(this);
        myshop_waiting_receive.setOnClickListener(this);
        myshop_waiting_comment.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //传数据
            case R.id.myshop_waiting_comment:
                OrderListActivity.actionStart(getActivity(), 3);
                break;
            case R.id.myshop_waiting_receive:
                OrderListActivity.actionStart(getActivity(), 2);
                break;
            case R.id.myshop_waiting_pay:
                OrderListActivity.actionStart(getActivity(), 1);
                break;
            case R.id.order_title:

                OrderListActivity.actionStart(getActivity(), 0);
                break;
            case R.id.setup:
                System.out.println("aaaaaaaaa");
                intent = new Intent(getActivity(), SetupUserActivity.class);
                startActivity(intent);
                break;
        }
    }


}
